
#pragma once

namespace NT
{
namespace RENDERER
{

class NtD3DRenderer;
class NtTexture;
class NtLightShader : public NtShader
{
	struct NtMatrixBuffer
	{
		D3DXMATRIX world;
		D3DXMATRIX view;
		D3DXMATRIX proj;
	};

	struct NtLightBuffer
	{
		D3DXVECTOR4 diffuseColor;
		D3DXVECTOR3 lightDirection;
		float padding;
	};

public:
	NtLightShader();
	~NtLightShader();

	bool Initialize(NtD3DRenderer* renderer, const NtWChar* vs, const NtWChar* ps);
	void Release();
	bool Render(NtD3DRenderer* renderer, int indexCount, const D3DXMATRIX& world, const D3DXMATRIX& view, const D3DXMATRIX& proj, NtTexture* texture, const D3DXVECTOR3& lightDir, const D3DXVECTOR4& diffuse);
private:
	bool InitializeShader(NtD3DRenderer* renderer, const NtWChar* vs, const NtWChar* ps);
	void ReleaseShader();

	bool SetShaderParameter(NtD3DRenderer* renderer, const D3DXMATRIX& world, const D3DXMATRIX& view, const D3DXMATRIX& proj, NtTexture* texture, const D3DXVECTOR3& lightDir, const D3DXVECTOR4& diffuse);
	void RenderShader(NtD3DRenderer* renderer, int indexCount);

private:
	ID3D11VertexShader* m_vertexShader;
	ID3D11PixelShader* m_pixelShader;
	ID3D11InputLayout* m_layout;
	ID3D11SamplerState* m_sampleState;
	ID3D11Buffer* m_matrixBuffer;
	ID3D11Buffer* m_lightBuffer;
};

}
}
